package com.chuanjiabao.wisdom.util.dialog;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;

import com.chuanjiabao.wisdom.R;
import com.chuanjiabao.wisdom.databinding.DialogWxHintBinding;
import com.chuanjiabao.wisdom.listener.OnBHClickListener;
import com.flyco.dialog.widget.base.BaseDialog;

public class WxHintDialog extends BaseDialog {

    private DialogWxHintBinding binding;
    private OnBHClickListener onBHClickListener;

    public WxHintDialog(Context context) {
        super(context);
        binding = DataBindingUtil.inflate(
                LayoutInflater.from(context),
                R.layout.dialog_wx_hint,
                null,
                false
        );
        binding.setDialog(this);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    }

    @Override
    public View onCreateView() {
        widthScale(0.85f);
        return binding.getRoot();
    }

    @Override
    public void setUiBeforShow() {
        setCancelable(false);
        setCanceledOnTouchOutside(false);
    }

    public void setOnBHClickListener(OnBHClickListener onBHClickListener) {
        this.onBHClickListener = onBHClickListener;
    }

    @Override
    public void dismiss() {
        super.dismiss();
        binding.dialogContent.destroy();
    }

    public void setTitleHint(String hint) {
        binding.dialogTitle.setText(hint);
    }

    public void setBtnHint(String hint) {
        binding.dialogNo.setText(hint);
    }

    public void setBtn2Hint(String hint) {
        binding.dialogYes.setText(hint);
    }

    public void setContent(String url) {
        binding.dialogContent.loadUrl(url);
    }

    public void setOneBtn() {
        binding.dialogYes.setVisibility(View.GONE);
        binding.dialogDivider.setVisibility(View.GONE);
    }

    public void noPoint(View view) {
        if (onBHClickListener != null) {
            onBHClickListener.onCloseClick();
        }
        dismiss();
    }

    public void okPoint(View view) {
        if (onBHClickListener != null) {
            onBHClickListener.onConfirmClick();
        }
        dismiss();
    }

}


